import { Button } from "@mui/material";
import React from "react";
import MyButton from "./MyButton";

export default function RandomButton(props) {
  const sleep = (time) => {
    return new Promise(function (resolve) {
      setTimeout(resolve, time);
    });
  };
  const solve = async () => {
    const len = (Math.ceil(Math.random() * 100) % 20) + 1;
    var a = [];
    for (var i = 0; i < len; ++i) {
      a.push((Math.ceil(Math.random() * 100) % 20) + 1);
    }
    console.log(a.join(","));
    props.setData(a.join(","));

    // setTimeout(props.solve, 1000);
  };
  return (
    <MyButton onClick={solve} loading={props.loading}>
      {props.loading ? "正在排序" : "随机生成数据"}
    </MyButton>
  );
}
